import numpy as np

line1=np.array([[2.835109,-1.131868],[-2.554651,-1.194638]],dtype=np.float32)
line2=np.array([[2.661071,-1.143387],[-2.661069,-1.143402]],dtype=np.float32)

k1=(line1[1,1]-line1[0,1])/(line1[1,0]-line1[0,0])
b1=line1[0,1]-k1*line1[0,0]

k2=(line2[1,1]-line2[0,1])/(line2[1,0]-line2[0,0])
b2=line2[0,1]-k2*line2[0,0]

x=(b2-b1)/(k1-k2)
y=k1*x+b1
print ("inter: ",x,y)
print ("v1: ",line1[1,0]-line1[0,0],line1[1,1]-line1[0,1])
print ("v2: ",x-line1[0,0],y-line1[0,1])
print ("v3: ",(x-line1[0,0])/(line1[1,0]-line1[0,0]),(y-line1[0,1])/(line1[1,1]-line1[0,1]))
print ("v4: ",line2[1,0]-line2[0,0],line2[1,1]-line2[0,1])
print ("v5: ",x-line2[0,0],y-line2[0,1])
print ("v6: ",(x-line2[0,0])/(line2[1,0]-line2[0,0]),(y-line2[0,1])/(line2[1,1]-line2[0,1]))


v1=line2[0,:]-line1[0,:]
v2=line2[1,:]-line1[0,:]
v3=line2[0,:]-line1[1,:]
v4=line2[1,:]-line1[1,:]

area_134=(v1[0]*v2[1]-v1[1]*v2[0])/2
area_234=(v3[0]*v4[1]-v3[1]*v4[0])/2
area_123=(v1[0]*v3[1]-v1[1]*v3[0])/2
area_124=(v2[0]*v4[1]-v2[1]*v4[0])/2

print ("area: ",area_134,area_234,area_123,area_124)
print ("lamda: ",area_134/(area_134-area_234))